<template>
  <div style="width: 100vw; height: 100vh;  display: flex; justify-content: center; align-items: center;">
    <el-form>
      <el-form-item>
        <el-input v-model="userForm.username"  placeholder="名称"/>
      </el-form-item>
      <el-form-item>
        <el-input v-model="userForm.password" placeholder="密码" />
      </el-form-item>
      <el-form-item >
        <el-button style="width: 100%" type="primary" @click="toLogin">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts" setup>
import { reactive} from 'vue'
import {login} from "../../api/LoginApi.ts";
import appStore from "../../store/appStore.ts";
import router from "../../router";

const app = appStore()


const userForm = reactive({
  id: 0,
  username: 'eren',
  password: 'eren'
})

const toLogin = async () => {
  const res = await login(userForm)
  if (res.code === 200) {
    app.token = res.data.token
    app.user = res.data.user
    await router.push('/home/system/user/list')
   }
}
</script>


